print "program begins..."
inputFileName = "/home/diaosi/gov2ClearYourMindAndDoItAgain/queryTermsFrom100KWithTheirTrueProbablityAndOurOwnModelPredictedProbablity1D_2D_GoodTuringProbabilityAdded20130429"
inputFileHandler = open(inputFileName,"r")

outputFileName = "/home/diaosi/gov2ClearYourMindAndDoItAgain/queryTermProbabilityDistribution_sortedByTerm"
outputFileHandler = open(outputFileName,"w")

# ignore the headline
headLine = inputFileHandler.readline()

for line in inputFileHandler.readlines():
    lineElements = line.strip().split(" ")
    queryTerm = lineElements[0]
    probabilityInStringFormat = lineElements[1]
    outputFileHandler.write(queryTerm + " " + probabilityInStringFormat + "\n")

inputFileHandler.close()
outputFileHandler.close()
print "program ends."